<template>
  <div>
    <div class="dialog">
      <el-dialog
        width="45%"
        title="补货详情"
        :visible="isShow"
        append-to-body
        @close="handleClose"
      >

        <div class="table">
          <el-table
            style="width: 100%"
            class="customer-table"
            :data="replenishDetails"
            height="500"
          >
            <el-table-column
              prop="channelCode"
              label="货道编号"
            />
            <el-table-column
              prop="sku.skuName"
              label="商品名称"
            />
            <el-table-column
              prop="currentCapacity"
              label="当前数量"
            />
            <el-table-column
              prop="expectCapacity"
              label="还可添加"
            />
            <el-table-column
              prop="maxCapacity"
              label="补满数量"
              width="150"
            >
              <template slot-scope="{row}">
                <el-form ref="num">
                  <el-form-item>
                    <el-input-number v-model="row.maxCapacity" controls-position="right" :min="0" :max="10" size="small" @change="handleChange" />
                  </el-form-item>
                </el-form>
              </template>
            </el-table-column>

          </el-table>

          <el-row slot="footer" type="flex" justify="center" align="middle" class="dialog-footer">
            <el-button type="warning" plain @click="handleClose">取消</el-button>
            <el-button v-loading="loading" type="primary" @click="submit">确认</el-button>
          </el-row>
        </div></el-dialog></div>

  </div>

</template>

<script>
export default {
  props: {
    isShow: {
      type: Boolean,
      default: false
    },
    replenishDetails: {
      type: Array,
      required: true
    }
  },
  data() {
    return {
      loading: false,
      detailsList: []
    }
  },
  methods: {
    submit() {
      const details = this.replenishDetails.filter(item => item.skuId !== '0')
      // console.log(details)
      this.detailsList = details.map(item => {
        item.skuName = item.sku.skuName
        item.skuImage = item.sku.skuImage
        // console.log(item.skuImage)
        return item
      })
      this.$emit('detailsList', this.detailsList)
      // console.log(this.detailsList)
      this.handleClose()
    },
    handleClose() {
      this.$emit('update:isShow', false)
      this.$refs.num.resetFields()
    },
    handleChange() {

    }
  }
}
</script>

<style lang="scss" scoped>
.table {

      ::v-deep .el-table th, .el-table tr th,td{
         background: rgb(243, 246, 251);
         border: none;
         font-size: 14px;
         color: #666;

    }
    ::v-deep.el-table {
      height: 368px !important;
      border-bottom: none !important;

    }

 }

 .el-button--primary {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 80px!important;
    height: 36px;
    padding: 0;
    font-size: 14px;
    background: linear-gradient(135deg,#ff9743,#ff5e20)!important;
    border: none;
     margin-left: 50px !important;

  }
  .el-button--warning.is-plain {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 80px!important;
    height: 36px;
    padding: 0;
    background-color: #fbf4f0!important;
    border: none;
    color: #655b56!important;
      font-size: 14px;

  }

</style>
